package com.doit.utils;/**
 * Created by hunter.coder 涛哥
 * 2019/4/17 15:15
 * 交流qq:657270652
 * Version: 1.0
 * 更多学习资料：https://blog.csdn.net/coderblack/
 * Description:
 **/

import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

/**
 * @Author hunter.coder
 * @Date 2019/4/17 15:15
 * @Version 1.0
 * @Description TODO
 **/
public class NginxSender {
    String url = "";
    CloseableHttpClient client = null;

    public NginxSender(String url) {
        this.url = url;
        client = HttpClientBuilder.create().build();
    }


    public void send(String msg) {
        if (StringUtils.isBlank(url)) return;

        HttpGet get = new HttpGet(url + "?log=" + msg);
        try {
            client.execute(get);
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
